package com.blb.edusearchservice.dao;

import com.blb.common.entity.PageEntity;
import com.blb.edusearchservice.entity.ElasticsearchEntity;

import java.io.IOException;
import java.util.List;
import java.util.Map;

public interface ElasticsearchDAO {

    boolean existsIndex(String indexName) throws IOException;

    void createIndex(String indexName) throws IOException;

    void deleteIndex(String indexName) throws IOException;

    void insertBatch(String indexName, List<ElasticsearchEntity> entities) throws IOException;

    <T> PageEntity<T> searchPageByMap(String indexName, int from, int size,
                                      Map<String,String> map,Map<String,String> sort, Class<T> c) throws IOException;

    /**
     * 更新或添加文档
     * @param indexName
     * @param entity
     */
    void saveOrUpdate(String indexName, ElasticsearchEntity entity) throws IOException;

    /**
     * 按id删除文档
     * @param indexName
     * @param id
     */
    void deleteById(String indexName, String id) throws IOException;
}
